package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

@Setter@Getter
public class CustomerTraceHistory {
    public static final int TYPE_COMMON=0;//潜在客户开发
    public static final int TYPE_FORMAL=1;//正式客户跟进

    private Long id;

    //跟进日期

   @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;


    private String traceDetails;

    private SystemDictionaryItem traceType;

    private Integer traceResult;

    private String remark;

    private Customer customer;

    private Employee inputUser;

    private Date inputTime;
    //跟进类型
    private Integer type;

    public String getJsonString(){
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id",id);
        SimpleDateFormat pattern = new SimpleDateFormat("yyyy-MM-dd");

        map.put("traceTime",pattern.format(traceTime));
       // map.put("traceTime",traceTime);
        map.put("traceDetails",traceDetails);
        map.put("traceType",traceType);
        map.put("traceResult",traceResult);
        map.put("remark",remark);
        map.put("type",type);
        if(customer !=null){
            map.put("customerId",customer.getId());
            map.put("customerName",customer.getName());
        }
        if(traceType != null){
            map.put("traceTypeId",traceType.getId());
        }




        return JSON.toJSONString(map);
    }

}